package com.bc.trade.config;


import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

import com.fs.common.util.FSJedis;
import com.fs.common.util.FSThreadPoolExecutor;

public class SystemInit {
	
	/**
	 * 初始化redis配置
	 */
	public static void initRedis(){
		String redisHost = SystemConfig.config.get("aliyun_redis_host");
		String password = SystemConfig.config.get("aliyun_redis_password");
		int maxIdle = SystemConfig.config.getInt("aliyun_redis_max_idle");
		int maxTotal = SystemConfig.config.getInt("aliyun_redis_max_total");
		FSJedis.setConfig(redisHost, password, maxIdle, maxTotal);
		System.out.println("------------------- 初始化redis配置成功 -------------------");
	}
	
	/**
	 * 初始化线程池配置
	 */
	public static void initThreadPoolExecutor(){
		int corePoolSie = SystemConfig.config.getInt("thread_corePoolSize");
		int maximumPoolSize = SystemConfig.config.getInt("thread_maximumPoolSize");
		long keepAliveTime = SystemConfig.config.getLong("thread_keepAliveTime");
		FSThreadPoolExecutor.init(corePoolSie, maximumPoolSize, keepAliveTime, TimeUnit.HOURS, new LinkedBlockingQueue<>());
		System.out.println("------------------- 初始化线程池配置成功 -------------------");
	}

}
